<?php
/*
	排队
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$merchid = intval($_RQ['merchid']);
if($_RQ['store_id']){
	$store_id = intval($_RQ['store_id']);
	$this->store_id=$store_id;
}
if(!$store_id){
	$store_id=$this->store_id;
}
if(!$store_id){
	exi('请先选择门店！','error','jy_weishop/index/');
}
if($_RQ['op']=='main'){
	$params=array(
		'uniacid'=>$_SESSION['uniacid'],
		'status'=>1,
	);	
	if($merchid){
		$params['merchid']=$merchid;
	}else{
		$params['store_id']=$store_id;
	}
	$queue = pdo_getall('jy_weishop_queue',$params,'','',' display desc');	
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$queue_num=pdo_getslice('jy_weishop_queue_member',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($queue_num){
		foreach($queue_num as &$v){
			$v['queuename'] = $queue[$v['queue_id']]['title'];
			$v['numid'] = $queue[$v['queue_id']]['pre'].$v['id'];
		}
	}
	//查询门店设置
	if($merchid){
		$setting=$this->plugin_setting('queue_merch'.$merchid);
	}else{
		$setting=$this->plugin_setting('queue_'.$store_id);
	}
	$return['params']=$params;
	$return['queue'] = $queue;
	$return['queue_num'] = $queue_num;
	$return['setting'] = $setting;
	set_html('title','排号大屏幕');
	exi($return);
}